package com.easy;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by Lxk on 2019/12/1.
 */
public class Solution1200 {

    public List<List<Integer>> minimumAbsDifference(int[] arr) {
        List<List<Integer>> res = new ArrayList<>();
        if (arr == null || arr.length == 0 || arr.length == 1) {
            return res;
        }

        List<Integer> dataList = new ArrayList<>();
        for (Integer val : arr) {
            dataList.add(val);
        }
        Collections.sort(dataList);
        int min = Integer.MAX_VALUE;
        for (int i = 1; i < dataList.size(); i++) {
            if (dataList.get(i) - dataList.get(i - 1) < min) {
                min = dataList.get(i) - dataList.get(i - 1);
            }
        }
        for (int i = 1; i < dataList.size(); i++) {
            if ((dataList.get(i) - dataList.get(i - 1)) == min) {
                List<Integer> temp = new ArrayList<>();
                temp.add(dataList.get(i - 1));
                temp.add(dataList.get(i));
                res.add(temp);
            }
        }
        return res;
    }
}
